package com.ag.zlw.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbLawnature;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;
import com.ag.zlw.service.LawnatureService;

/**
 * 法规性质
 * 
 * @author 钟龙伟
 * 
 */

@Scope("prototype")
@Controller("LawnatureAction")
public class LawnatureAction extends BaseAction {
	private static final long serialVersionUID = -1478025497648926124L;
	@Resource(name = "LawnatureService")
	private LawnatureService service;
	private List<TbLawnature> LawnatureList;
	private String message;
	private String lnId;
	private String lnName;

	TbLawnature tbLawnature = new TbLawnature();

	public String find() {
		try {
			LawnatureList = service.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "main";
	}

	public String delete() {
		tbLawnature.setLnId(lnId);
		try {
			service.delete(tbLawnature);
			this.setMessage("delete success!");
		} catch (Exception e) {
			this.setMessage("delete fail!");
		}
		return "delete_success";
	}

	public String add() {
		tbLawnature.setLnName(lnName);
		tbLawnature.setA(IDUtil.PRESERVE);
		try {
			service.save(tbLawnature);
			this.setMessage("save success!");
		} catch (Exception e) {
			this.setMessage("save fail!");
		}
		return "add_success";
	}

	public String modify() {
		tbLawnature.setLnId(lnId);
		tbLawnature.setLnName(lnName);
		tbLawnature.setA(IDUtil.PRESERVE);
		try {
			service.modify(tbLawnature);
			this.setMessage("modify success!");
		} catch (Exception e) {
			this.setMessage("modify fail!");
		}
		return "modify_success";
	}

	public List<TbLawnature> getLawnatureList() {
		return LawnatureList;
	}

	public void setLawnatureList(List<TbLawnature> lawnatureList) {
		this.LawnatureList = lawnatureList;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getLnId() {
		return lnId;
	}

	public void setLnId(String lnId) {
		this.lnId = lnId;
	}

	public String getLnName() {
		return lnName;
	}

	public void setLnName(String lnName) {
		this.lnName = lnName;
	}

}
